#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from sqlalchemy import Column, Integer, String, Date, DECIMAL, BigInteger
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

sys.path.append(r"web")
sys.path.append(r"algorithm")
sys.path.append(r"cta")

# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'adam3.settings')
# django.setup()


class EtfTransactionData(Base):
    """
    日线级别ETF数据
    """

    __tablename__ = 'etf_transaction_data'

    # 主键
    id_ = Column(BigInteger, primary_key=True, autoincrement=True)

    # 日期
    date_ = Column(Date)

    # 代码
    code_ = Column(String(32))

    # 最高价
    highest_price = Column(DECIMAL(32, 3))

    # 最低价
    lowest_price = Column(DECIMAL(32, 3))

    # 开盘价
    open_price = Column(DECIMAL(32, 3))

    # 最新价/收盘价
    close_price = Column(DECIMAL(32, 3))

    # 前收盘
    last_close_price = Column(DECIMAL(32, 3))

    # 涨跌额
    change_amount = Column(DECIMAL(32, 3))

    # 涨跌幅
    change_range = Column(DECIMAL(32, 3))

    # 成交量
    volume = Column(DECIMAL(32, 3))

    # 成交额
    turnover = Column(DECIMAL(32, 3))

    # 5日均线
    ma5 = Column(DECIMAL(32, 3))

    # 10日均线
    ma10 = Column(DECIMAL(32, 3))

    # 20日均线
    ma20 = Column(DECIMAL(32, 3))

    # 60日均线
    ma60 = Column(DECIMAL(32, 3))

    # 120日均线
    ma120 = Column(DECIMAL(32, 3))

    # 250日均线
    ma250 = Column(DECIMAL(32, 3))

    # MACD的ema12
    ema12 = Column(DECIMAL(32, 3))

    # MACD的ema26
    ema26 = Column(DECIMAL(32, 3))

    # MACD的dif
    dif = Column(DECIMAL(32, 3))

    # MACD的dea
    dea = Column(DECIMAL(32, 3))

    # MACD的macd
    macd = Column(DECIMAL(32, 3))

    # KD的rsv
    rsv = Column(DECIMAL(32, 3))

    # KD的k
    k = Column(DECIMAL(32, 3))

    # KD的d
    d = Column(DECIMAL(32, 3))

    # HeiKinAshi最高价
    ha_highest_price = Column(DECIMAL(32, 3))

    # HeiKinAshi最低价
    ha_lowest_price = Column(DECIMAL(32, 3))

    # HeiKinAshi开盘价
    ha_open_price = Column(DECIMAL(32, 3))

    # HeiKinAshi收盘价
    ha_close_price = Column(DECIMAL(32, 3))

    # 5日bias
    bias5 = Column(DECIMAL(32, 3))

    # 10日bias
    bias10 = Column(DECIMAL(32, 3))

    # 20日bias
    bias20 = Column(DECIMAL(32, 3))

    # 60日bias
    bias60 = Column(DECIMAL(32, 3))

    # 120日bias
    bias120 = Column(DECIMAL(32, 3))

    # 250日bias
    bias250 = Column(DECIMAL(32, 3))

    # 和上证指数的5日相关系数
    correlation5_with000001 = Column(DECIMAL(32, 3))

    # 和深证成指的5日相关系数
    correlation5_with399001 = Column(DECIMAL(32, 3))

    # 和中小板指数的5日相关系数
    correlation5_with399005 = Column(DECIMAL(32, 3))

    # 和创业板指数的5日相关系数
    correlation5_with399006 = Column(DECIMAL(32, 3))

    # 和平均收盘价的5日相关系数
    correlation5_with_avg_c_p = Column(DECIMAL(32, 3))

    # 和平均收盘价的250日相关系数
    correlation250_with_avg_c_p = Column(DECIMAL(32, 3))
